
from rest_framework import serializers
from . import models

class CouponModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.Coupon
        fields = ['id','name', 'condition', 'coupon_type','sale']


class UserCouponModelSerializer(serializers.ModelSerializer):
    # name = serializers.CharField(source='coupon.name')
    # condition = serializers.CharField(source='coupon.condition')
    coupon = CouponModelSerializer()
    class Meta:
        model = models.UserCoupon
        fields = ['id',  'start_time','end_time','coupon']

